<!DOCTYPE html>
<html>
<head>
    <title>Neo4j Connection Test</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            padding: 40px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
        }
        .container {
            max-width: 800px;
            margin: 0 auto;
            background: white;
            padding: 30px;
            border-radius: 10px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.2);
        }
        h1 { color: #333; }
        .info-box {
            background: #f0f0f0;
            padding: 20px;
            border-radius: 8px;
            margin: 20px 0;
        }
        .status {
            padding: 15px;
            border-radius: 8px;
            margin: 20px 0;
        }
        .success { background: #d4edda; color: #155724; }
        .error { background: #f8d7da; color: #721c24; }
        .warning { background: #fff3cd; color: #856404; }
        a {
            display: inline-block;
            padding: 12px 24px;
            background: #667eea;
            color: white;
            text-decoration: none;
            border-radius: 5px;
            margin: 10px 5px;
        }
        a:hover { background: #5a67d8; }
        code {
            background: #f4f4f4;
            padding: 2px 6px;
            border-radius: 3px;
        }
        .query-box {
            background: #2d3748;
            color: #e2e8f0;
            padding: 15px;
            border-radius: 5px;
            font-family: 'Courier New', monospace;
            margin: 10px 0;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>🔗 Neo4j Connection Guide</h1>

        <div class="status warning">
            <h2>⚠️ WebSocket Connection Issue</h2>
            <p>The browser cannot connect via WebSocket to Neo4j. This is a common issue with the following solutions:</p>
        </div>

        <h2>✅ Solution Options:</h2>

        <div class="info-box">
            <h3>Option 1: Use Direct IP Address (Recommended)</h3>
            <p>Instead of using <code>localhost</code>, use your server's IP address:</p>
            <ol>
                <li>Access Neo4j Browser at: <strong>http://192.168.0.153:7474</strong> (or your server's IP)</li>
                <li>In the connection dialog, use:
                    <ul>
                        <li>Connection URL: <code>bolt://192.168.0.153:7687</code></li>
                        <li>Username: <code>neo4j</code></li>
                        <li>Password: <code>neo4j123</code></li>
                    </ul>
                </li>
            </ol>
            <a href="http://192.168.0.153:7474" target="_blank">Open Neo4j Browser (IP)</a>
        </div>

        <div class="info-box">
            <h3>Option 2: Use Command Line (cypher-shell)</h3>
            <p>Connect via terminal for direct database access:</p>
            <div class="query-box">cypher-shell -u neo4j -p neo4j123</div>
            <p>Then run queries directly, for example:</p>
            <div class="query-box">MATCH (n:Node) RETURN n.label, n.type, n.degree ORDER BY n.degree DESC LIMIT 10;</div>
        </div>

        <div class="info-box">
            <h3>Option 3: SSH Tunnel (For Remote Access)</h3>
            <p>If accessing from a remote machine, create an SSH tunnel:</p>
            <div class="query-box">ssh -L 7474:localhost:7474 -L 7687:localhost:7687 user@your-server</div>
            <p>Then access locally at <code>http://localhost:7474</code></p>
        </div>

        <h2>📊 Sample Queries to Try:</h2>

        <div class="info-box">
            <h4>Find Top Nodes:</h4>
            <div class="query-box">MATCH (n:Node)<br>RETURN n.label, n.type, n.degree<br>ORDER BY n.degree DESC<br>LIMIT 20</div>

            <h4>View Node Types:</h4>
            <div class="query-box">MATCH (n:Node)<br>RETURN n.type, count(n) as count<br>ORDER BY count DESC</div>

            <h4>Find Dependencies:</h4>
            <div class="query-box">MATCH (n:Node {type: 'class'})-[:DEPENDS_ON]->(m:Node)<br>WHERE n.degree > 50<br>RETURN n, m<br>LIMIT 50</div>
        </div>

        <div class="status success">
            <h2>✅ Database Status</h2>
            <ul>
                <li>Neo4j is running on ports 7474 (HTTP) and 7687 (Bolt)</li>
                <li>Total Nodes: 7,518</li>
                <li>Total Edges: 37,980</li>
                <li>Database Name: neo4j</li>
            </ul>
        </div>

        <h2>🔧 Quick Actions:</h2>
        <a href="http://localhost:7474" target="_blank">Neo4j Browser (Localhost)</a>
        <a href="http://192.168.0.153:7474" target="_blank">Neo4j Browser (IP)</a>
        <a href="/neo4j_guide.md" target="_blank">View Full Guide</a>
    </div>
</body>
</html>